# -*- mode: python ; coding: utf-8 -*-

from PyInstaller.utils.hooks import collect_data_files, collect_submodules
datas = collect_data_files('chromadb', include_py_files=True, includes=['**/*.py', '**/*.sql'])
# datas.append(('data', 'data'))
a = Analysis(
    ['main.py'],
    pathex=['C:\\lp\\code\\llm\\LDLLM\\'],
    binaries=[],
    datas=datas,
    hiddenimports=['onnxruntime', 'tokenizers', 'chromadb.telemetry.product.posthog', 'chromadb.telemetry.posthog', 'chromadb.api.segment','chromadb.db.impl',
'chromadb.db.impl.sqlite','chromadb.migrations', 'chromadb.migrations.embeddings_queue', 'hnswlib','passlib.handlers.bcrypt'],
    collectsubmodules=['chromadb', 'chromadb.migrations', 'chromadb.telemetry', 'chromadb.api','chromadb.db'],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    Tree('.\\data',prefix='data\\'),
    [],
    exclude_binaries=True,
    name='yunhanAGI',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=['yunhan\\favicon.png'],
)
coll = COLLECT(
    exe,
    a.binaries,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='main',
)

import shutil
def copy_extra_resources(src_folder, dest_folder):
#    src_folder = 'path/to/your/folder'
    dest_folder = os.path.join(DISTPATH, dest_folder)
    if not os.path.exists(dest_folder):
        shutil.copytree(src_folder, dest_folder)

block_cipher = None
# 添加下面两行来调用复制函数
copy_extra_resources('./data', './main/data')
copy_extra_resources('./yunhan', './main/yunhan')
copy_extra_resources('./static', './main/static')